<?php 
// Load up the backend's settings plus the file containing the login related functions
include 'options_meta.php';
include 'login.php';
login('index.php');

if ($_POST) {
	//save out the settings
	//Due to the fact that a HTML checkbox when unchecked well be null
	//It is not possible to merge existing file with the new POST data since once checked a checkbox could not be unchecked
	//If you happen not to need checkboxes then use the following code to reimplament non-destructive saving
	// array_filter($_POST);
	// if (file_exists("settings.ini")) {
	// $setting = unserialize(file_get_contents("settings.ini"));
	// }
	// $setting = array_merge($setting , $_POST);

	//As such all settings must be printed in the options page and resent over POST each time
	//save out the settings
	$settings = $_POST;
	file_put_contents("settings.ini", serialize($settings));
} else if (file_exists("settings.ini")) {
	//Load the settings only if we don't already have the settings
	$settings = unserialize(file_get_contents("settings.ini"));
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $backend_name;?> Configuration</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="backdrop">
<div id="admin_main">
<div id="header">
	<h3 class="page_title"><?php echo $backend_name;?></h3>
</div>
<div id="content">
	<form name="input" action="index.php" method="post" enctype="multipart/form-data">
		<table border="0" cellspacing="0">
			<?php include 'options.php'; //The custom set of options is loaded and displayed here ?>
			<tr><td>&nbsp;</td><td><button type="submit" class="button positive"><img src="css/blueprint/plugins/buttons/icons/tick.png" alt=""/> Save</button></td></tr>
		</table>
	</form>
	</div>
</div>
</div>
</body>
</html>